package com.guyu.common.core.validator.constraints;


import com.guyu.common.core.enums.YesOrNoEnum;
import com.guyu.common.core.enums.able.IEnum;
import com.guyu.common.core.validator.constraintvalidators.IEnumLimitValidatorImpl;
import jakarta.validation.Constraint;
import jakarta.validation.Payload;

import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

@Target({METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER})
@Retention(RUNTIME)
@Documented
@Constraint(validatedBy = IEnumLimitValidatorImpl.class)
public @interface EnumLimit {

    String message() default "值必须在{iEnum}的code范围内";

    /**
     * 枚举class
     */
    Class<? extends IEnum> iEnum() default YesOrNoEnum.class;

    Class<?>[] groups() default {};

    Class<? extends Payload>[] payload() default {};

    /**
     * Defines several {@link EnumLimit} annotations on the same element.
     *
     * @see EnumLimit
     */
    @Target({METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER})
    @Retention(RUNTIME)
    @Documented
    @interface List {

        EnumLimit[] value();
    }
}
